package com.itheima.controller;

import com.itheima.domain.InnerMarketDomain;
import com.itheima.domain.StockBlockDomain;
import com.itheima.domain.StockUpdownDomain;
import com.itheima.service.StockService;
import com.itheima.vo.resp.PageResult;
import com.itheima.vo.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/quot")
@Api("大盘板块")
public class StockController {
    @Autowired
    private StockService stockService;

    /**
     * 查询最新的国内大盘信息
     * @return
     */
    @ApiOperation("查询最新的国内大盘信息")
    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getInnerIndexAll() {
        List<InnerMarketDomain> domains = stockService.getInnerIndexAll();
        return R.ok(domains);
    }

    /**
     *板块指数
     * @return
     */
    @GetMapping("/sector/all")
    @ApiOperation("板块指数")
    public R<List<StockBlockDomain>> sectorAll(){
        List<StockBlockDomain> domains = stockService.sectorAllLimit();
        return R.ok(domains);
    }

    /**
     * 涨幅榜更多数据功能实现
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/stock/all")
    @ApiOperation(("涨幅榜更多数据功能实现"))
    public R<PageResult<StockUpdownDomain>> stockAll(Integer page, Integer pageSize){
        PageResult<StockUpdownDomain> pageResult = stockService.stockAll(page,pageSize);
        return R.ok(pageResult);
    }

    /**
     * 涨幅榜功能
     * @return
     */
    @GetMapping("/stock/increase")
    @ApiOperation(("涨幅榜功能"))
    public R<List<StockUpdownDomain>> increase(){
        List<StockUpdownDomain> stockUpdownDomains = stockService.increase();
        return R.ok(stockUpdownDomains);
    }

}
